package com.lyb.controller;

import com.lyb.pojo.User;
import com.lyb.service.UserService;
import com.lyb.utils.Result;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("user")
@CrossOrigin
@Tag(name = "用户接口列表")
public class UserController {

    @Autowired
    private UserService service;

    @PostMapping("login")
    public Result login(@RequestBody User user){
        Result result = service.login(user);
        return result;
    }

    @PostMapping("register")
    public Result register(@RequestBody User user){
        Result result = service.register(user);
        return result;
    }

    @PutMapping
    public Result updateUser(@RequestBody User user){
        Result result = service.updateUser(user);
        return result;
    }

    @GetMapping("getUser/{id}")
    public Result getUser(@PathVariable Integer id){
        Result result = service.getUser(id);
        return result;
    }
}
